From: kfraser@localhost.localdomain Date: Mon, 23 Oct 2006 08:57:24 +0000 (+0100) Subject: [ACM] Don't use uninitialised struct value if hypercall fails. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15585^2~25 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=94ee555a3aee8f3cf8c3575410c69d85a1496397;p=xen.git [ACM] Don't use uninitialised struct value if hypercall fails. From: Jan Beulich Signed-off-by: Keir Fraser --- diff --git a/tools/python/xen/lowlevel/acm/acm.c b/tools/python/xen/lowlevel/acm/acm.c index ec39b60bb4..930c568212 100644 --- a/tools/python/xen/lowlevel/acm/acm.c +++ b/tools/python/xen/lowlevel/acm/acm.c @@ -147,9 +147,10 @@ static PyObject *getdecision(PyObject * self, PyObject * args) { char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL; struct acm_getdecision getdecision; - int xc_handle; + int xc_handle, rc; - if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2)) { + if (!PyArg_ParseTuple(args, "ssss", &arg1_name, + &arg1, &arg2_name, &arg2)) { return NULL; } @@ -179,13 +180,17 @@ static PyObject *getdecision(PyObject * self, PyObject * args) getdecision.id2.ssidref = atol(arg2); } - if (xc_acm_op(xc_handle, ACMOP_getdecision, &getdecision, sizeof(getdecision)) < 0) { + rc = xc_acm_op(xc_handle, ACMOP_getdecision, + &getdecision, sizeof(getdecision)); + + xc_interface_close(xc_handle); + + if (rc < 0) { if (errno == EACCES) PERROR("ACM operation failed."); + return NULL; } - xc_interface_close(xc_handle); - if (getdecision.acm_decision == ACM_ACCESS_PERMITTED) decision = "PERMITTED"; else if (getdecision.acm_decision == ACM_ACCESS_DENIED)